<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
 <html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">
 <base href="<%=basePath%>">
   <title>预约详情</title>
  <jsp:include page="bs/bs.jsp"></jsp:include>
  <style type="text/css">
  	.div_h{
  	border:1px solid #ccc;

  	}
  .form-control{
  	width:40%;
  }
  </style>
  <script type="text/javascript">
  	function checkDate(){
  		// 校验日期   预约日期不能是 周六周日  也不能是今天之前的日期
  		var f = true;
  		var a = $("#odate").val();   // 2022-04-20
  		//alert(a);
  		var date = new Date();  // 当前日期
  		var as = a.split("-");  // 字符串转数组
  		var y = as[0];  //2022
  		var m = as[1];  // 04
  		var d = as[2];  // 20
  		var dt = new Date(as[0], as[1]-1, as[2]);
  		if(date>=dt){
  			// 选择了当前日期 之前的日期
  			f = false;
  		}else{
  			// 选择了 周六 或者 周日
  			if(dt.getDay()==0 || dt.getDay()==6){
  				f = false;
  			}
  		}
  		if(!f){
  			$("#odate").val(null);
  			alert("预约时间不合法");
  		}
  	}
  	function check(){
  		var rq = $("#odate").val();
  		var sj = $("#sjdid").val();
  		if(rq!=null && sj!=null){
  			$.ajax({
  				url:"${pageContext.request.contextPath}/checkDate",
				//odate 预约日期
				//edid 预约医生
				// sjdid 时间段id  页面显示预约时间段 向后台提交的是  tid
  				data:{odate:$("#odate").val(),edid:$("#edid").val(),sjdid:$("#sjdid").val()},
  				type:"get",
  				success:function(data){
  					if(data.code==200){
						$("#ss").html("可预约");
						$("#btn").attr("disabled",false);
  					}else{
						$("#ss").html("预约人数已满");
						$("#btn").attr("disabled",true);
					}
  				}, dataType:"json"
  			}

			);
  		}

  	}

  </script>
  </head>
<!-- NAVBAR
================================================== -->
  <body>
   <c:if test="${empty u }">
  	<c:redirect url="login.jsp"></c:redirect>
  </c:if>

	<jsp:include page="common/top.jsp"></jsp:include>


    <div class="container"  >
	    <div class="col-lg-4 " style="text-align: center;">
	    	<img  src="${doc.durl }" width="200px" height="200px">
	    </div>
		<div class="col-lg-8 div_h">
			<form action="${pageContext.request.contextPath}/addOrder" method="post">
			<h1>${doc.drealname }&nbsp; 医生</h1>
			${doc.zw }&nbsp;&nbsp;&nbsp;${doc.zy }&nbsp;&nbsp;&nbsp;${doc.xl }
			<input type="hidden" id="edid" name="edid" value="${doc.did }">
			<input type="hidden" id="dmoney" name="dmoney" value="${doc.dmoney }">
			<br>
			<br>
			预约日期：
			<input type="date" id="odate" name="odate" class="form-control" onblur="checkDate()"><span id="sp"></span>
			<br>
			预约时间：
			<select id="sjdid" class="form-control" name="sjdid" onchange="check()">
				<option value="" >请选择时间</option>
				<c:if test="${!empty ts }">
					<c:forEach items="${ts }" var="tss">
						<c:if test="${tss.tgroup==6 }">
							<option value="${tss.tid }">${tss.tname }</option>
						</c:if>
					</c:forEach>
				</c:if>
			</select>
			<span id="ss"></span>
			<br>
			病情：
			<textarea rows="5" cols="100" name="sickness"  class="form-control">
			</textarea>
			<br>
			<button type="submit" id="btn" class="btn btn-primary"  style="width: 40%">现在预约</button>
			${xq_info }
			<br>
			门诊信息：${doc.ks }
			</form>

		</div>

	</div>
		<br>
		<br>
	<div class="container">

		<div class="col-lg-12 div_h">
			<h4>医生简介：</h4>
			<br>
			${doc.dtext }
		</div>
		<div class="col-lg-12 div_h">
			<h4>用户评论:</h4>
			<br>
			<c:if test="${!empty cs }">
				<c:forEach items="${cs }" var="c">
					<div class="table table-hover col-lg-12">
						<c:if test="${c.pnm==1}">
							<b>匿名用户&nbsp;</b>
						</c:if>
						<c:if test="${c.pnm==0}">
							<b>${c.pname }&nbsp;</b>
						</c:if>
						${c.ptime }
						<br>
						${c.ptext }
					</div>
				</c:forEach>

			</c:if>
			<c:if test="${empty cs }">
			暂无评论
			</c:if>

		</div>

	</div>


  <jsp:include page="common/footer.jsp"></jsp:include>


  </body>
</html>

